package org.vsg.security.model.service.impl;

import java.io.Serializable;
import java.util.Collection;

import org.vsg.common.biz.exception.ServiceException;
import org.vsg.common.pagination.Pagination;
import org.vsg.common.pagination.PaginationException;
import org.vsg.common.pagination.carrier.Carrier;
import org.vsg.common.pagination.carrier.RecordLimitCarrier;
import org.vsg.common.pagination.datatrans.PaginationProvider;
import org.vsg.common.pagination.datatrans.PaginationProviderFactory;
import org.vsg.security.model.domain.SysOperation;
import org.vsg.security.model.persistence.SysOperationDao;
import org.vsg.security.model.service.SysOperationService;


public class SysOperationServiceImpl implements SysOperationService {
	/**
	 * set the pagination provider factory
	 * 
	 * 
	 */
	private PaginationProviderFactory factory = PaginationProviderFactory
			.getInstance();

	private SysOperationDao sysOperationDao;

	/**
	 * @param carrier
	 * @return
	 * @exception ServiceException
	 * @exception PaginationException
	 */
	public Pagination pageSysOperation(Carrier carrier) throws ServiceException,
			PaginationException {
		// TODO: implement
		PaginationProvider provider = factory
				.generateProvider((RecordLimitCarrier) carrier);
		return sysOperationDao.pageSysOperation(provider);
	}

	/**
	 * @param carrier
	 * @return
	 * @throws ServiceException
	 * @exception PaginationException
	 */
	public Pagination pageSysOperationByAll(Carrier carrier) throws ServiceException,
			PaginationException {
		// TODO: implement
		PaginationProvider provider = factory
				.generateProvider((RecordLimitCarrier) carrier);
		return sysOperationDao.pageSysOperationByAll(provider);
	}
	
	@Override
	public void saveAll(Collection<SysOperation> all)
			throws ServiceException {
		// TODO Auto-generated method stub
		sysOperationDao.saveAll(all);
		
	}  	

	/**
	 * @param sysOperation
	 * @exception ServiceException
	 */
	public void addSysOperation(SysOperation sysOperation) throws ServiceException {
		// TODO: implement
		sysOperationDao.save(sysOperation);
	}

	/**
	 * @param sysOperation
	 * @exception ServiceException
	 */
	public void updateSysOperation(SysOperation sysOperation) throws ServiceException {
		// TODO: implement
		sysOperationDao.update(sysOperation);
	}

	/**
	 * @param sysOperation
	 * @exception ServiceException
	 */
	public void updateSimpleSysOperation(SysOperation newEntity) throws ServiceException {
		// TODO: implement
		SysOperation original = sysOperationDao.load( newEntity.getId() );
		
		original.setId( newEntity.getId()  );
		original.setType( newEntity.getType()  );
		
		// --- update the method ---
		sysOperationDao.update( original );		
		
	}

	/**
	 * @param sysOperation
	 * @exception ServiceException
	 */
	public void deleteSysOperation(SysOperation sysOperation) throws ServiceException {
		// TODO: implement
		sysOperationDao.delete(sysOperation);
	}

	@Override
	public void deleteAll(Collection<SysOperation> all)
			throws ServiceException {
		// TODO Auto-generated method stub
		sysOperationDao.deleteAll(all);
	}
	

	/**
	 * @param pk
	 * @exception ServiceException
	 */
	public SysOperation loadSysOperation(Serializable pk) throws ServiceException {
		// TODO: implement
		return sysOperationDao.load(pk);
	}


	@Override
	public Collection<SysOperation> findByAll() throws ServiceException {
		// TODO Auto-generated method stub
		return sysOperationDao.findByAll();
	}


	public SysOperationDao getSysOperationDao() {
		return sysOperationDao;
	}

	/**
	 * @param newSysOperationDao
	 */
	public void setSysOperationDao(SysOperationDao newSysOperationDao) {
		sysOperationDao = newSysOperationDao;
	}




}